<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: CuentasController</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">CuentasController</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/controllers/cuentas_controller_rb.html">
                app/controllers/cuentas_controller.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="ApplicationController.html">
                ApplicationController
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000160">create</a>&nbsp;&nbsp;
      <a href="#M000162">destroy</a>&nbsp;&nbsp;
      <a href="#M000159">edit</a>&nbsp;&nbsp;
      <a href="#M000155">for_manager</a>&nbsp;&nbsp;
      <a href="#M000154">index</a>&nbsp;&nbsp;
      <a href="#M000158">new</a>&nbsp;&nbsp;
      <a href="#M000156">show</a>&nbsp;&nbsp;
      <a href="#M000157">show_all</a>&nbsp;&nbsp;
      <a href="#M000161">update</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000160" class="method-detail">
        <a name="M000160"></a>

        <div class="method-heading">
          <a href="#M000160" class="method-signature">
          <span class="method-name">create</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
POST /cuentas POST /cuentas.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000160-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000160-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 74</span>
74:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
75:     <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:cuenta</span>])
76:                 <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
77:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">save</span>
78:                 <span class="ruby-ivar">@usuario_cuenta</span> = <span class="ruby-constant">UsuarioCuenta</span>.<span class="ruby-identifier">new</span>
79:                                 <span class="ruby-ivar">@usuario_cuenta</span>.<span class="ruby-identifier">cuenta_id</span> = <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">id</span>
80:                                 <span class="ruby-ivar">@usuario_cuenta</span>.<span class="ruby-identifier">user_id</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">id</span>
81:                                 <span class="ruby-ivar">@usuario_cuenta</span>.<span class="ruby-identifier">save</span> 
82:     
83:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-identifier">cuentas_path</span>) }
84:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:created</span>, <span class="ruby-identifier">:location</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span> }
85:       <span class="ruby-keyword kw">else</span>
86:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;new&quot;</span> }
87:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">errors</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:unprocessable_entity</span> }
88:       <span class="ruby-keyword kw">end</span>
89:     <span class="ruby-keyword kw">end</span>
90:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000162" class="method-detail">
        <a name="M000162"></a>

        <div class="method-heading">
          <a href="#M000162" class="method-signature">
          <span class="method-name">destroy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
DELETE /cuentas/1 DELETE /cuentas/1.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000162-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000162-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 111</span>
111:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy</span>
112:     <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
113:    
114:     <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">destroy</span>
115: 
116:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
117:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-identifier">cuentas_path</span>) }
118:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">head</span> <span class="ruby-identifier">:ok</span> }
119:     <span class="ruby-keyword kw">end</span>
120:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000159" class="method-detail">
        <a name="M000159"></a>

        <div class="method-heading">
          <a href="#M000159" class="method-signature">
          <span class="method-name">edit</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /cuentas/1/edit
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000159-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000159-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 68</span>
68:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit</span>
69:         <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
70:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000155" class="method-detail">
        <a name="M000155"></a>

        <div class="method-heading">
          <a href="#M000155" class="method-signature">
          <span class="method-name">for_manager</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000155-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000155-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 26</span>
26:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">for_manager</span>
27:         <span class="ruby-ivar">@titulo</span> = <span class="ruby-value str">&quot;de &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-constant">AccountManager</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user_id</span>]).<span class="ruby-identifier">nombre</span>
28:         <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find_all_by_manager_id</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user_id</span>])
29:         <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
30:                 <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;index&quot;</span> }
31:         <span class="ruby-keyword kw">end</span>
32:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000154" class="method-detail">
        <a name="M000154"></a>

        <div class="method-heading">
          <a href="#M000154" class="method-signature">
          <span class="method-name">index</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /cuentas GET /cuentas.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000154-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 8</span>
 8:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span>
 9:           
10:          <span class="ruby-identifier">user_id</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user_id</span>]
11:          <span class="ruby-identifier">contacto_id</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:contacto_id</span>]
12:           
13:          <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">user_id</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span> 
14:           <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">search_asignadas</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:search</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:page</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user_id</span>]) 
15:          <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">contacto_id</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span> 
16:                <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">search_contactos</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:search</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:page</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:contacto_id</span>])
17:          <span class="ruby-keyword kw">else</span> 
18:                <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">search</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:search</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:page</span>])
19:          <span class="ruby-keyword kw">end</span>   
20:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
21:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># index.html.erb</span>
22:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuentas</span> }
23:     <span class="ruby-keyword kw">end</span>
24:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000158" class="method-detail">
        <a name="M000158"></a>

        <div class="method-heading">
          <a href="#M000158" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /cuentas/new GET /cuentas/new.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000158-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000158-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 58</span>
58:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new</span>
59: 
60:         <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">new</span>
61:         <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
62:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># new.html.erb</span>
63:           <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span> }
64:         <span class="ruby-keyword kw">end</span>
65:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000156" class="method-detail">
        <a name="M000156"></a>

        <div class="method-heading">
          <a href="#M000156" class="method-signature">
          <span class="method-name">show</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /cuentas/1 GET /cuentas/1.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000156-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000156-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 36</span>
36:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show</span>
37:     <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
38: 
39:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
40:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">js</span>
41:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># show.html.erb</span>
42:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span> }
43:     <span class="ruby-keyword kw">end</span>
44:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000157" class="method-detail">
        <a name="M000157"></a>

        <div class="method-heading">
          <a href="#M000157" class="method-signature">
          <span class="method-name">show_all</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /cuentas/1 GET /cuentas/1.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000157-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000157-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 48</span>
48:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show_all</span>
49:     <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>)
50: 
51:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
52:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># show.html.erb</span>
53:     <span class="ruby-keyword kw">end</span>
54:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000161" class="method-detail">
        <a name="M000161"></a>

        <div class="method-heading">
          <a href="#M000161" class="method-signature">
          <span class="method-name">update</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
PUT /cuentas/1 PUT /cuentas/1.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000161-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000161-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/cuentas_controller.rb, line 94</span>
 94:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update</span>
 95:   
 96:   
 97:     <span class="ruby-ivar">@cuenta</span> = <span class="ruby-constant">Cuenta</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
 98:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
 99:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">update_attributes</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:cuenta</span>])
100:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-identifier">cuentas_path</span>) }
101:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">head</span> <span class="ruby-identifier">:ok</span> }
102:       <span class="ruby-keyword kw">else</span>
103:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;edit&quot;</span> }
104:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@cuenta</span>.<span class="ruby-identifier">errors</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:unprocessable_entity</span> }
105:       <span class="ruby-keyword kw">end</span>
106:     <span class="ruby-keyword kw">end</span>
107:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>